<?
$ds = clone GET();

if ( $ds->exists( 'h' ) && $ds->isEmpty( 'h' ) == false )
{
	$test = unserialize( base64_decode( $ds->h ) );
	if ( is_array( $test ) )
	{
	    $ds->set( $test );
		$ds->merge( GET() );
	}
}
$form = load_form( 'generate/form' );
$form->processor( URL( 'generate/form' ) );
$form->ds( clone $ds );
echo $form->render();

if ( $ds->dataPresent )
{
	$ds->setVar( 'formId', str_replace( ' ', '_', strtolower( str_replace( '-', '_', basename( $ds->form ) ) ) ) . '_form' );
	
	$ds->setVar( 'formClassName', lcfirst( str_replace( ' ', '', ucwords( str_replace( '_', ' ', basename( $ds->form ) ) ) ) . 'Form' ) );
	
	$ds->setVar( 'form_name', basename( $ds->model ) );


	ob_start();
	include view( 'generate/form' );

	$code = htmlentities( ob_get_clean() );
	?>
	
	Structure for the Fields:
<pre>Group1
field_name|field type|caption
Group2
field_name|field type|caption
field_name|field type|caption
</pre>
	<textarea style="font-family: courier; width: 100%; height:100%;"><?= $code; ?></textarea><?php
}
